﻿namespace WolfCarol.SFU
{
    public abstract class Entity
    {
        public bool IsAlive { get; private set; }

        private bool _isStarted = false;

        public virtual void OnStart() { }
        public virtual void OnUpdate() { }
        public virtual void OnDestroy() { }

        public void Start()
        {
            if (_isStarted == true)
            {
                return;
            }

            _isStarted = true;
            IsAlive = true;
            OnStart();
        }

        public void Update()
        {
            if (IsAlive == false)
            {
                return;
            }

            OnUpdate();
        }

        public void Destroy()
        {
            IsAlive = false;
            OnDestroy();
        }
    }
}
